/// @tags: Greek
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <numeric>
#include <vector>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 2e5 + 2;

int n, maxm;
double maxval;
int m[maxn], k[maxn];

struct BucketItem {
  int id, val;
} buc[maxn];

void solve(int t, std::vector<int> &ans) {
  for (int i = 1; i <= maxm; ++i) buc[i].id = i, buc[i].val = 0;
  for (int i = 1; i <= n; ++i) {
    buc[m[i]].val += std::min(t, k[i]);
  }
  std::sort(buc + 1, buc + maxm + 1,
            [](const BucketItem &lhs, const BucketItem &rhs) -> bool {
              return lhs.val > rhs.val;
            });
  int sum = 0;
  for (int i = 1; i <= t; ++i) {
    sum += buc[i].val;
  }
  double tmp = (double)sum / t;
  if (tmp > maxval) {
    maxval = tmp;
    ans.clear();
    for (int i = 1; i <= t; ++i) {
      ans.push_back(buc[i].id);
    }
  }
}

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> m[i] >> k[i];
    maxm = std::max(maxm, m[i]);
  }
  std::vector<int> ans;
  for (int i = 1; i <= 20; ++i) {
    solve(i, ans);
  }
  cout << ans.size() << '\n';
  for (auto &&i : ans) {
    cout << i << ' ';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("CF1612E Messages.in", "r", stdin);
  freopen("CF1612E Messages.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
